﻿Public Class Form1

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim originalText As String
        Dim nowText As String = ""
        Dim posStart As Integer
        Dim posEnd As Integer
        Dim numStr As String
        Dim originalArray(32) As Integer
        Dim nowArray(32) As Integer
        Dim i As Integer
        Dim j As Integer
        posStart = 1
        posEnd = 1
        On Error GoTo EXIT_SUB
        Do While (posStart <> 0)
            originalText = RichTextBox1.Text
            posStart = InStr(posEnd, originalText, "/*")
            posEnd = InStr(posStart, originalText, "*/")
            nowText = nowText + Mid(originalText, posStart, posEnd - posStart + 2) + Chr(13)
            For i = 1 To 32
                posStart = InStr(posEnd, originalText, "0x")
                posEnd = InStr(posStart, originalText, ",")
                Dim test As String
                test = Mid(originalText, posStart + 2, posEnd - posStart - 2)
                originalArray(i) = (Val("&H" + test))
            Next
            Dim test1 As Integer
            ReDim nowArray(32)
            For j = 1 To 8
                For i = 1 To 8
                    test1 = (((originalArray(2 * i - 1) >> (8 - j)) And &H1) << (i - 1))
                    nowArray(j) = nowArray(j) + test1
                Next
            Next j
            For j = 1 To 8
                For i = 1 To 8
                    test1 = (((originalArray(2 * i) >> (8 - j)) And &H1) << (i - 1))
                    nowArray(8 + j) = nowArray(8 + j) + test1
                Next
            Next j
            For j = 1 To 8
                For i = 1 To 8
                    test1 = (((originalArray(2 * i - 1 + 16) >> (8 - j)) And &H1) << (i - 1))
                    nowArray(j + 16) = nowArray(j + 16) + test1
                Next
            Next j
            For j = 1 To 8
                For i = 1 To 8
                    test1 = (((originalArray(2 * i + 16) >> (8 - j)) And &H1) << (i - 1))
                    nowArray(j + 24) = nowArray(j + 24) + test1
                Next
            Next j
            For j = 1 To 32
                nowText = nowText + "0x" + Hex(nowArray(j)) + ","
            Next
            nowText = nowText + Chr(13)
        Loop
EXIT_SUB:
        RichTextBox2.Text = nowText
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Dim originalText As String
        Dim nowText As String = ""
        Dim posStart As Integer
        Dim posEnd As Integer
        Dim numStr As String
        Dim originalArray(16) As Integer
        Dim nowArray(16) As Integer
        Dim i As Integer
        Dim j As Integer
        posStart = 1
        posEnd = 1
        On Error GoTo EXIT_SUB
        Do While (posStart <> 0)
            originalText = RichTextBox1.Text
            posStart = InStr(posEnd, originalText, "/*")
            posEnd = InStr(posStart, originalText, "*/")
            nowText = nowText + Mid(originalText, posStart, posEnd - posStart + 2) + Chr(13)
            For i = 1 To 16
                posStart = InStr(posEnd, originalText, "0x")
                posEnd = InStr(posStart, originalText, ",")
                Dim test As String
                test = Mid(originalText, posStart + 2, posEnd - posStart - 2)
                originalArray(i) = (Val("&H" + test))
            Next
            Dim test1 As Integer
            ReDim nowArray(16)
            For j = 1 To 8
                For i = 1 To 8
                    test1 = (((originalArray(i) >> (8 - j)) And &H1) << (i - 1))
                    nowArray(j) = nowArray(j) + test1
                Next
            Next j
            For j = 1 To 8
                For i = 1 To 8
                    test1 = (((originalArray(i + 8) >> (8 - j)) And &H1) << (i - 1))
                    nowArray(j + 8) = nowArray(j + 8) + test1
                Next
            Next j
            For j = 1 To 16
                nowText = nowText + "0x" + Hex(nowArray(j)) + ","
            Next
            nowText = nowText + Chr(13)
        Loop
EXIT_SUB:
        RichTextBox2.Text = nowText
    End Sub

    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        Dim originalText As String
        Dim nowText As String = ""
        Dim posStart As Integer
        Dim posEnd As Integer
        Dim numStr As String
        Dim originalArray(16) As Integer
        Dim nowArray(16) As Integer
        Dim i As Integer
        Dim j As Integer
        posStart = 1
        posEnd = 1
        On Error GoTo EXIT_SUB
        Do While (posStart <> 0)
            originalText = RichTextBox1.Text
            posStart = InStr(posEnd, originalText, "/*")
            posEnd = InStr(posStart, originalText, "*/")
            nowText = nowText + Mid(originalText, posStart, posEnd - posStart + 2) + Chr(13)
            posStart = InStr(posEnd, originalText, "/*")
            posEnd = InStr(posStart, originalText, "*/")
            nowText = nowText + Mid(originalText, posStart, posEnd - posStart + 2) + Chr(13)
            For i = 1 To 16
                posStart = InStr(posEnd, originalText, "0x")
                posEnd = InStr(posStart, originalText, ",")
                Dim test As String
                test = Mid(originalText, posStart + 2, posEnd - posStart - 2)
                originalArray(i) = (Val("&H" + test))
            Next
            Dim test1 As Integer
            ReDim nowArray(16)
            For j = 1 To 8
                For i = 1 To 8
                    test1 = (((originalArray(i) >> (8 - j)) And &H1) << (i - 1))
                    nowArray(j) = nowArray(j) + test1
                Next
            Next j
            For j = 1 To 8
                For i = 1 To 8
                    test1 = (((originalArray(i + 8) >> (8 - j)) And &H1) << (i - 1))
                    nowArray(j + 8) = nowArray(j + 8) + test1
                Next
            Next j
            For j = 1 To 16
                nowText = nowText + "0x" + Hex(nowArray(j)) + ","
            Next
            nowText = nowText + Chr(13)
        Loop
EXIT_SUB:
        RichTextBox2.Text = nowText
    End Sub
End Class
